package kr.saeildamil.androidstudy.ch08;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Toast;

public class HandlerOrder extends Activity {
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		View view = new View(this);
		
		// Listener 우선순위 1
		view.setOnTouchListener(new OnTouchListener() {
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					Toast.makeText(HandlerOrder.this,
							"Listener: Touch Event Received.",
							Toast.LENGTH_SHORT).show();
					// return true;
				}
				return false;
			}
		});
		//*/
		setContentView(view);
	}

	protected class MyView extends View {

		public MyView(Context context) {
			super(context);
		}
		// View 우선순위 2
		public boolean OnTouchEvent(MotionEvent event) {
			if (event.getAction() == MotionEvent.ACTION_DOWN) {
				Toast.makeText(HandlerOrder.this, "View: Touch Event Received",
						Toast.LENGTH_SHORT).show();
			 // return true;
			}
			return false;
		}
		//*/
	}
	
	// Activity 우선순위 3
	public boolean OnTouchEvent(MotionEvent event) {
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			Toast.makeText(HandlerOrder.this, "Activity: Touch Event Received",
					Toast.LENGTH_SHORT).show();
			// return true;
		}
		return false;
	}
	//*/
}